
<template>
  <div class="newsLisftMenu" v-if="list.length">
    <span @click="handlerClick(item)" :class="[{active:$route.query.columnId==item.columnId}]" v-for="(item,index) in list" :key="index" >{{item.title}}</span>
  </div>
</template>

<script>
export default {
  name: "newsLisftMenu",
  computed:{
    menuList(){
      return this.$store.getters.menuList
    },
  },
  watch:{
    menuList:{
      handler(v){
        if(v.length!=0){
          this.getSubMenus()
        }
      },
      immediate:true,
      deep:true
    }
  },
  mounted(){
    // this.getSubMenus()
  },
  data(){
    return {
      list:[]
    }
  },
  methods:{
    getSubMenus(){
      let name = this.$route.query.columnId
      let list = []
      this.menuList.some(x=>{
        if(x.routerList.includes(parseInt(name))){
          list = x.childMenusTreeVO
          return true
        }
      })
      this.list = list
    },
    handlerClick(item){
      this.$emit('handlerClick',item)
    },
  },
}
</script>

<style scoped lang="less">
.newsLisftMenu{
  width: 120px;
  height: 100%;
  background-color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  span{
    font-size: 16px;
    color: #303860;
    border-radius: 16px;
    padding: 6px 12px;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.3s;
    &:hover{
      color: white;
      background-color: #3772FF ;
    }
  }
  .active{
    color: white;
    background-color: #3772FF ;
  }
}
</style>
